exports.add=[{
	_type:"functions",
	_section:"Nav",

	calc: function() {
		if (this.calc_pages) return;
		this.calc_pages={active: {},root_id:undefined,path:[this.pageinfo],pages:{}};
		if (!this.pageinfo) return;
		var p=this.pageinfo.id;
		this.calc_pages.root_id=p;
		this.calc_pages.active[p]=1;
		this.calc_pages.pages[p]=this.pageinfo;
		p=this.pageinfo.parent_id;
		while (p) {
			this.calc_pages.root_id=p;
			this.calc_pages.active[p]=1;
			var page=this.site.models.Page.Get(p);
//			var page=this.site.sql.execute_and_fetch_one("nav/get_page",{page_id:p});
			this.calc_pages.pages[page.id]=page;
			this.calc_pages.path.unshift(page);
			p=page.parent_id;
		}

	}
}];

